package com.it.educms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.it.educms.entity.CrmBanner;
import com.it.educms.mapper.CrmBannerMapper;
import com.it.educms.service.CrmBannerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 首页banner表 服务实现类
 * </p>
 *
 * @author test.java
 * @since 2021-03-27
 */
@Service
public class CrmBannerServiceImpl extends ServiceImpl<CrmBannerMapper, CrmBanner> implements CrmBannerService {
    //查询所有的banner
    @Cacheable(value="banner",key="'selectIndexList'")
    public List<CrmBanner> selectAllBanner() {
        //通过id进行降序排列 显示两条记录
        QueryWrapper<CrmBanner>wrapper=new QueryWrapper<CrmBanner>();
        wrapper.orderByDesc("id");
        //排序 查前两条
        wrapper.last("limit 2");
        List<CrmBanner> list = baseMapper.selectList(null);
        return list;
    }
}

